// 初始化处理template数据
const unitConf = {
    multiLang: {
        domainName: 'uapbd',
        currentLocale: 'zh-CN',
        moduleId: 'refer_uapbd',
    },
    key: 'pk_org',
    refType: 'tree',
    refName: 'refer-000176', /* 国际化处理： 行政组织*/
    placeholder: 'refer-000176', /* 国际化处理： 行政组织*/
    refCode: 'uapbd.org.AdminOrgDefaultTreeRef',
    queryTreeUrl: '/nccloud/riaorg/ref/AdminOrgDefaultTreeRef.do',
    treeConfig: {name: ['refer-000002', 'refer-000003'], code: ['refcode', 'refname']}, /* 国际化处理： 编码,名称*/
    rootNode: {refname: 'refer-000176', refpk: 'root'}, /* 国际化处理： 行政组织*/
    isMultiSelectedEnabled: false
};

export default function setQueryMeta() {
    let meta = this.props.meta.getMeta(), that = this,
        tab = this.props.tabKey === 'contract' ? 'contractquery' : 'agreementquery';

    meta[tab].items.forEach(item => {
        if (item.itemtype === 'refer' && item.attrcode !== 'pk_dept') {
            item.queryCondition = function () {
                return {
                    "pk_org": that.props.orgVal.refpk
                }
            }
        }
        switch (item.attrcode) {
            case 'pk_dept':
                unitConf.queryCondition = function () {
                    return {
                        keyword: item.attrcode,
                        pk_org: that.props.orgVal.refpk,
                        TreeRefActionExt: 'nccloud.web.hrhi.pub.sqlbuilder.OrgRefNoPowerSqlBuilder'
                    }
                };
                item.isShowUnit = true;
                item.unitProps = unitConf;
                item.defaultUnitValue = {
                    refpk: that.props.orgVal.refpk
                };
                break;
            case 'pk_post':
            case 'pk_org':
                item.queryCondition = {
                    keyword: item.attrcode,
                    TreeRefActionExt: 'nccloud.web.hrcm.account.sqlbuilder.HRCMAccountQuerySqlBuilder'
                };
                break;
            case 'hi_psndoc_ctrt.pk_conttext':
                item.queryCondition = {
                    keyword: item.attrcode,
                    pk_org: that.props.orgVal.refpk,
                    GridRefActionExt: 'nccloud.web.hrcm.account.sqlbuilder.HRCMAccountQuerySqlBuilder'
                };
                break;
            default:
                break;
        }
    });
    this.props.meta.setMeta(meta);
}
